Contents

  1. You want to do what?!?
  2. Getting started
  3. The desktop
  4. A pseudo-base class
  5. Joy and grief
  6. Timing is everything (or sometimes nothing)
  7. Conclusions / Lessons Learned

My very own base class - sort of

For menus and images, I needed more than what Component provided, but didn't want to duplicate code everywhere. This class helps. It has several attributes and accessors, and calls the default serialization methods.
public class DesktopComponent extends Component implements Serializable {
	String label;

	DesktopComponent() {
		super();
	}

	DesktopComponent( String s ) {
		super();
		this.setLabel( s );
	}

	public void setLabel( String s ) {
		this.label = s;
	}

	public String getLabel() {
		return this.label;
	}

	public void setX( int i ) {
		this.setLocation( i, this.getLocation().y );
	}

	public int getX() {
		return this.getLocation().x;
	}

	public void setY( int i ) {
		this.setLocation( this.getLocation().x, i );
	}

	public int getY() {
		return this.getLocation().y;
	}

	public void setWidth( int i ) {
		this.setSize( i, this.getSize().height );
	}

	public int getWidth() {
		return this.getSize().width;
	}

	public void setHeight( int i ) {
		this.setSize( this.getSize().width, i );
	}

	public int getHeight() {
		return this.getSize().height;
	}

	private void writeObject( ObjectOutputStream s ) throws IOException {
		s.defaultWriteObject();
	}

	private void readObject( ObjectInputStream s ) throws ClassNotFoundException, IOException {
		s.defaultReadObject();
	}
}

PreviousNext